﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _02.HumanClasses
{
    public class Worker : Human
    {
        private double weekSalary;
        private byte workHoursPerDay; 

        public Worker(string firstName, string secondName, double weekSalary, byte workHoursPerDay) 
            : base(firstName, secondName)
        {
            this.weekSalary = weekSalary;
            this.workHoursPerDay = workHoursPerDay;
        }

        public byte WorkHoursPerDay
        {
            get
            {
                return this.workHoursPerDay;
            }
            set
            {
                if (value < 0)
                {
                    throw new ArgumentOutOfRangeException("The week working hours cannot be negative");
                }
                this.workHoursPerDay = value;
            }
        }

        public double WeekSalary
        {
            get
            {
                return this.weekSalary;
            }
            set
            {
                if (value < 0)
                {
                    throw new ArgumentOutOfRangeException("The week salary cannot be negative");
                }
                this.weekSalary = value;
            }
        }

        public double MoneyPerHour()
        {
            return this.weekSalary / (5 * this.workHoursPerDay);
        }

        public override string ToString()
        {
            return string.Format("{0} {1}  week salary: {2} work hours: {3} Money per hour: {4:F4}",
                firstName, lastName, weekSalary, workHoursPerDay, MoneyPerHour());
        }
    }
}